<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>投票</title>
</head>
<body>
<h1 align="center">{{ question.question_text }}</h1>
问题选项如下：<br/>


  {% if error_message %}
    <p>
      <strong>{{ error_message }}</strong>
    </p>
  {% endif %}

  <form action="{% url "polls:vote"  question.id %}" method="post">
    {% csrf_token %}
    {% for choice in question.choice_set.all %}
      <input type="radio" name="choice"
             id="choice{{ forloop.counter }}" value="{{  choice.id }}">
      <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label>
    {% endfor %}
  <input type="submit" value="投票">
  </form>
















<!-- 前端写法 -->
<ul>
  {% for choice in question.choice_set.all %}  <!-- 前端中后面不带括号 -->
    <li>{{ choice.choice_text }}--{{ choice.votes }}</li>
  {% endfor %}
</ul>


<!-- 建议把所有业务逻辑放在后端 -->
<!-- 后端写法 -->
{#<ul>#}
{#  {% for foo in choices %}#}
{#  <li>{{ foo.choice_text }}--{{ foo.votes }}</li>#}
{#  {% empty %}#}
{#      <li>没有问题选项</li>#}
{#  {% endfor %}#}
{#</ul>#}
</body>
</html>